import axios from 'axios'

let axiosurl = "http://localhost:9003"

const service = axios.create({
    baseURL: axiosurl
});


// 创建axios 赋值给常量service 

service.interceptors.request.use(function (config) {
    return config;
},
    function (error) {
        return Promise.reject(error)
    });
service.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    return Promise.reject(error)
})
service.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    //  打印下看看当错误的时候干什么
    console.log("aaaaaa", error.response.status);
    switch (error.response.status) {
        case 404:
            console.log("url信息有误")
            break;
        case 500:
            console.log("服务器有问题")
            break;

        default:
            console.log("未知错误")
            break;
    }
});



export default service